﻿@using SCMS.Resource
@model SCMS.UI.Models.AdvanceRequestModel
@{AjaxOptions ajaxOpts = new AjaxOptions
  {
      UpdateTargetId = "R4ADiv",
      LoadingElementId = "loading",
      HttpMethod = "Post",
      Url = Url.Action("SubmitRFA"),
      OnSuccess = "initSorter(); sorter.size(10);",
      Confirm = Resources.Global_String_SubmitForReview
  };} 
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<div class="partialViewCard">
    <div class="partialViewCardHeader"><h3>@Model.RefNumber</h3></div>
    @using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form" }))
    {
        @Html.ValidationSummary(true)
        <br />
        <table width="98%" align="center" border="0" cellpadding="2" cellspacing="2" style=" border-bottom: 1px solid Grey;">
            <tr class="gridheader">
                <td colspan="3">
                    @Resources.Global_String_SubjectPurpose
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <b>@Model.Subject</b>
                    @Html.HiddenFor(x => x.Subject)
                </td>
            </tr>
            <tr class="gridheader">
                <td>
                    @Resources.Request4Advance_CreateRFA_PaymentTo
                </td>
                <td>
                    @Resources.Global_String_PaymentTerms
                </td>
                <td>
                    @Resources.Global_String_PaymentType
                </td>
            </tr>
            <tr>
                <td align="center">
                    @Model.Payee
                    @Html.HiddenFor(x => x.PaidTo)
                </td>
                <td align="center">
                    @Model.PaymentTerm
                    @Html.HiddenFor(x => x.PaymentTermId)
                </td>
                <td align="center">
                    @Model.PaymentType
                    @Html.HiddenFor(x => x.PaymentTypeId)
                </td>
            </tr>
            <tr class="gridheader">
                <td width="33%">
                    @Resources.Global_String_Date
                </td>
                <td width="33%">
                    @Resources.Global_String_Currency
                </td>
                <td width="34%">
                    @Resources.Global_String_TotalPayment
                </td>
            </tr>
            <tr>
                <td align="center">
                    @Model.RequestDate.ToString("dd/MM/yyyy")
                    @Html.HiddenFor(m => m.RequestDate)
                    @Html.HiddenFor(m => m.Id)
                </td>
                <td align="center">
                    @Model.Currency
                    @Html.HiddenFor(x => x.CurrencyId, new { @id = "currencyId" })
                </td>
                <td align="center">
                    <b>@Model.TotalAdvance.ToString("#,##0.00")</b>
                    @Html.HiddenFor(m => m.TotalAdvance)
                </td>
            </tr>
        </table>
        <br />    
        
        <table class="cardTable" cellpadding="2">
            <tr class="gridheader">
                <th colspan="5" align="center">@Resources.Global_String_PaymentDetails</th>
            </tr>
            @if (Model.PaymentDetails.Count > 0)
            { 
                <tr class="gridheader">
                    <th align="center">@Resources.Request4Advance_CreateRFADetail_RequestFor</th>
                    <th align="center">@Resources.Global_String_Description</th>
                    <th align="center">@Resources.Budget_CategoryList_ProjectNo</th>
                    <th align="center">@Resources.Budget_CreateSubLine_LineNumber</th>
                    <th align="center">@Resources.Global_String_Amount</th>
                </tr>
                foreach (var detail in Model.PaymentDetails)
                { 
                    <tr>
                        <td>@detail.AdvanceOption</td>
                        <td>@detail.Description</td>
                        <td>@detail.ProjectNo</td>
                        <td>@detail.BudgetLine</td>
                        <td align="right">@detail.Amount.ToString("#,###.00")</td>
                    </tr>
                }
                <tr>
                    <td align="right" colspan="5"><b>@Model.TotalAdvance.ToString("#,##0.00")</b></td>
                </tr>
            }
        </table>
        <br /> 
        
        <table width="98%" align="center" border="0" cellpadding="2" cellspacing="2">
            <tr class="gridheader">
                <td width="100%" colspan="2">
                    @Resources.Request4Advance_LoadRFADetails2_DetailedDescription
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    @Html.TextAreaFor(x => x.Description, new { @rows = "3", @id="tbDescription" })
                    @Html.ValidationMessageFor(x => x.Description)
                </td>
            </tr>
            <tr class="gridheader">
                <td width="100%" colspan="2">
                    @Resources.Request4Advance_LoadRFADetails2_SupportingDocuments
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    @Html.TextAreaFor(x => x.DocDescription, new { @rows = "3" })
                </td>
            </tr>
            <tr class="gridheader">
                <td  colspan="2">
                    @Resources.Global_String_Remarks
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    @Html.TextAreaFor(x => x.Remarks, new { @rows = "3" })
                </td>
            </tr>
            <tr>
                <td>
                    <input type="button" class="btn green" value="<< @Resources.Global_String_Prev" onclick="sendRequest('/Request4Advance/LoadRFADetails/@Model.Id', 'R4ADiv', 'loading')" />
                </td>
                <td align="right">
                    <input type="submit" class="btn green" value="@Resources.Global_String_SubmitForReview" />
                </td>
            </tr>
        </table>
    }
</div>

